home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 17 / AMIGAplus Sonderheft 17 (1999)(ICP)(DE)[!].iso / Rexx / LightTool.pprx < prev    next >
Text File  |  1997-05-06  |  4KB  |  165 lines

  1. /* Personal Paint Amiga Rexx script - Copyright © 1997 Cloanto Italia srl */
  2.  
  3. /* $VER: LightTool.pprx 1.0 */
  4.  
  5. /** ENG
  6.  This tool lightens (left mouse button) or darkens
  7.  (right mouse button) the image area it is used on.
  8.  
  9.  The tool uses the current brush. The predefined
  10.  one-pixel brush is ideal for use on single pixels.
  11.  Different "oil painting" effects can be achieved
  12.  with brushes in different sizes and shapes.
  13. */
  14.  
  15. /** DEU
  16.  Durch die Anwendung dieses Skripts auf einen  bestimmten Bildbereich läßt
  17.  sich dieser wahlweise abdunkeln (linke Maustaste) oder aufhellen (Rechte
  18.  Maustaste).
  19.  
  20.  Zur Ausführung dieses Werkzeugs wird der aktuelle Pinsel verwendet. Der
  21.  vordefinierte, einen Punkt große Pinsel ist zur Bearbeitung einzelner Pixel
  22.  ideal geeignet. Mit Pinseln unterschiedlicher Größen und Formen lassen sich
  23.  unterschiedliche "Ölgemälde"-Effekte erzielen. */
  24.  
  25. /** ITA
  26.  Questo strumento schiarisce (tasto sinistro del mouse) o scurisce
  27.  (tasto delstro del mouse) l'area dell'immagine su cui è usato.
  28.  
  29.  Lo strumento utilizza il pennello attuale. Il pennello predefinito
  30.  di un pixel è l'ideale per l'uso su pixel singoli.
  31.  Si possono ottenere diversi effetti a "pittura a olio" con pennelli
  32.  aventi forme e dimensioni varie.
  33. */
  34.  
  35. IF ARG(1, EXISTS) THEN
  36.     PARSE ARG PPPORT button x0 y0 .
  37. ELSE
  38.     EXIT 0  /* macro execution only */
  39.  
  40. ADDRESS VALUE PPPORT
  41. OPTIONS RESULTS
  42. OPTIONS FAILAT 10000
  43.  
  44. Version 'REXX'
  45. IF RESULT < 7 THEN DO
  46.     Get 'LANG'
  47.     IF RESULT = 1 THEN        /* Deutsch */
  48.         txt_err_oldclient = 'Für dieses Skript_ist eine neuere Version_von Personal Paint erforderlich'
  49.     ELSE IF RESULT = 2 THEN        /* Italiano */
  50.         txt_err_oldclient = 'Questa procedura richiede_una versione più recente_di Personal Paint'
  51.     ELSE                /* English */
  52.         txt_err_oldclient = 'This script requires a newer_version of Personal Paint'
  53.  
  54.     RequestNotify 'PROMPT "'txt_err_oldclient'"'
  55.     EXIT 10
  56. END
  57.  
  58. prev_xp = x0
  59. prev_yp = y0
  60. drawn = 0
  61. GetPaintMode
  62. svpmode = RESULT
  63. GetPen 'FOREGROUND'
  64. svfpen = RESULT
  65. SetPaintMode 'COLOR'
  66. Get 'COLORS'
  67. cnum = RESULT
  68. light. = ''
  69. dark. = ''
  70.  
  71. DO FOREVER
  72.     GetMousePosition
  73.     PARSE VAR RESULT xp yp .
  74.  
  75.     IF xp ~= prev_xp | yp ~= prev_yp | ~drawn THEN DO
  76.         IF ~drawn THEN DO
  77.             xp = x0
  78.             yp = y0
  79.         END
  80.         GetPixel xp yp
  81.         pxcol = RESULT
  82.         GetColors 'FROM' pxcol 'TO' pxcol 'HSV'
  83.         PARSE VAR RESULT hue sat val .
  84.         excl = pxcol
  85.         exnum = 1
  86.         newpxcol = -1
  87.         IF button = 1 THEN DO
  88.             IF light.pxcol = '' THEN DO
  89.                 IF val < 100 THEN DO
  90.                     val = val + 1
  91.                     DO FOREVER
  92.                         FindColor 'COLOR "'hue sat val'" HSV EXCLUDE "'excl'"'
  93.                         col = RESULT
  94.                         GetColors 'FROM' col 'TO' col 'HSV'
  95.                         PARSE VAR RESULT hue2 sat2 val2 .
  96.                         dhue = DeltaHue(hue, hue2)
  97.                         IF val2 > val & dhue < 20 THEN DO
  98.                             newpxcol = col
  99.                             LEAVE
  100.                         END
  101.                         excl = excl col
  102.                         exnum = exnum + 1
  103.                         IF exnum = cnum THEN
  104.                             LEAVE
  105.                     END
  106.                 END
  107.                 light.pxcol = newpxcol
  108.             END
  109.             ELSE newpxcol = light.pxcol
  110.         END
  111.         ELSE DO
  112.             IF dark.pxcol = '' THEN DO
  113.                 IF val > 0 THEN DO
  114.                     val = val - 1
  115.                     DO FOREVER
  116.                         FindColor 'COLOR "'hue sat val'" HSV EXCLUDE "'excl'"'
  117.                         col = RESULT
  118.                         GetColors 'FROM' col 'TO' col 'HSV'
  119.                         PARSE VAR RESULT hue2 sat2 val2 .
  120.                         dhue = DeltaHue(hue, hue2)
  121.                         IF val2 < val & dhue < 20 THEN DO
  122.                             newpxcol = col
  123.                             LEAVE
  124.                         END
  125.                         excl = excl col
  126.                         exnum = exnum + 1
  127.                         IF exnum = cnum THEN
  128.                             LEAVE
  129.                     END
  130.                 END
  131.                 dark.pxcol = newpxcol
  132.             END
  133.             ELSE newpxcol = dark.pxcol
  134.         END
  135.         IF newpxcol >= 0 THEN DO
  136.             SetPen 'FOREGROUND' newpxcol
  137.             PutBrush xp yp
  138.         END
  139.         prev_xp = xp
  140.         prev_yp = yp
  141.         drawn = 1
  142.     END
  143.     ELSE WaitForEvent
  144.  
  145.     GetMouseButton
  146.     IF RESULT ~= button THEN
  147.         LEAVE
  148. END
  149.  
  150. SetPen 'FOREGROUND' svfpen
  151. SetPaintMode svpmode
  152.  
  153. EXIT
  154.  
  155.  
  156.  
  157. DeltaHue: PROCEDURE
  158.  
  159.     h1 = ARG(1)
  160.     h2 = ARG(2)
  161.     d1 = ABS(h1-h2)
  162.     d2 = 360 - MAX(h1,h2) + MIN(h1,h2)
  163.  
  164.     RETURN MIN(d1,d2)
  165.